/**
*      author: Y_Yao
*      created: 2025-02-20 18:43:23
**/
//并查集 + 分组背包
#include<bits/stdc++.h>

#define int LL
using namespace std;
using LL = long long;
const LL LLINF = 1e18;
const int INF = 0x3f3f3f3f;
const int N = 2e3 + 7;
int n,m,k;
int f[N],fa[N],sz[N];
int b[N],w[N],B[N],W[N];
vector<int> fri[N];


int find(int x)
{
    if(fa[x] == x) return x;
    else fa[x] = find(fa[x]);
    return fa[x];
}

void Union(int u,int v)
{
    u = find(u);
    v = find(v);
    if(u == v) return;
    if(sz[u] > sz[v]) swap(u,v);
    fa[u] = v;
    B[v] += B[u]; 
    W[v] += W[u]; 
}

void solve()
{
    cin >> n >> m >> k;
    for(int i = 1;i <= n;i++)
    {
        cin >> w[i];
    }
    for(int i = 1;i <= n;i++)
    {
        cin >> b[i];
        W[i] = w[i];
        B[i] = b[i];
        fa[i] = i;
        sz[i] = 1; 
    }
    for(int i = 1;i <= m;i++)
    {
        int a,b;
        cin >> a >> b;
        Union(a,b);
    }

    //分组
    for(int i = 1;i <= n;i++)
    {
        int root = find(i);
        fri[root].push_back(i);
    }

    //放入
    int cnt = n;
    vector<bool> vis(n+1,false);
    for(int i = 1;i <= n;i++)
    {
        int root = find(i);
        if(!vis[root])
        {
            fri[root].push_back(++cnt);
            w[cnt] = W[root];
            b[cnt] = B[root];
            vis[root] = true;
        }
    }

    int ans = 0;
    for(int i = 1;i <= n;i++)
    {
        for(int h = k;h >= 0;h--)
        {
            for(int j = 0;j < fri[i].size();j++)
            {
                int e = fri[i][j];
                if(h >= w[e])
                f[h] = max(f[h],f[h-w[e]] + b[e]); 
            }
        }
    }
    cout << f[k] << endl;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    //cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}